var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = t("Const"),
    r = (function () {
        function t(e) {
            (this.id = 0), (this.is_destory = !1), (this.url = ""), t.uid++, (this.uid = t.uid), (this.type = e);
        }
        return (
            (t.getBundle = function (t) {
                var e = {name: "res", url: t},
                    o = t.indexOf("/");
                if (o > -1) {
                    var r = t.slice(0, o);
                    n.default.bundleNames.includes(r) && ((e.name = r), (e.url = t.slice(o + 1)));
                }
                return e;
            }),
            (t.prototype.load = function (e) {
                (this.url = e), this.id++;
                var o = this.id,
                    n = this,
                    r = t.getBundle(e);
                return new Promise(function (t, a) {
                    var i = cc.assetManager.getBundle(r.name);
                    if (null == i) throw Error("not find bundle " + r.name);
                    var s = i.getInfoWithPath(r.url, n.type);
                    if (null == s) throw Error("没有这个资源" + e);
                    var c = cc.assetManager.assets.get(s.uuid);
                    c
                        ? t(c)
                        : i.load(r.url, n.type, function (e, r) {
                              if (e) console.log(e), a(e);
                              else {
                                  if (n.is_destory) return void 0;
                                  o == n.id && t(r);
                              }
                          });
                });
            }),
            (t.prototype.destory = function () {
                this.is_destory = !0;
            }),
            (t.uid = 0),
            t
        );
    })();
o.default = r;
